import Vue from 'vue'
import VueRouter from 'vue-router'
import Inverter from '../views/Inverter'
import Alarm from '../views/Alarm'
import remoterRoutes from './remote'
import localRoutes from './local'
import agentRoutes from './agent'
import bluetoothRoutes from './bluetooth'

Vue.use(VueRouter)

const routes = [
    ...remoterRoutes,
    ...localRoutes,
    ...agentRoutes,
    ...bluetoothRoutes,
    //登录
    {
        path: "/",
        redirect: to => {
            if (localStorage.getItem('role') == 5 && localStorage.getItem('remember')) {
                return '/main/sitedetail'
            } else if (localStorage.getItem('role') == 3 && localStorage.getItem('remember')) {
                return '/agentIndex'
            } else {
                return '/login'
            }
        }
    },
    {
        path: '/login',
        name: 'Login',
        component: () =>
            import ('../views/Login.vue')
    },
    //扫描SN
    {
        path: '/scan',
        name: 'scan',
        component: () =>
            import ('../views/scan/scan.vue')
    },
    {
        path: '/bindsn',
        name: 'bindsn',
        component: () =>
            import ('../views/scan/bindsn.vue')
    },
    {
        path: '/camera',
        name: 'camera',
        component: () =>
            import ('../views/scan/camera.vue')
    },
    //扫描安装指南
    {
        path: '/scanguide',
        name: 'scanguide',
        component: () =>
            import ('../views/scan/camera2.vue')
    },
    //注册
    {
        path: '/signone',
        name: '/Signone',
        component: () =>
            import ('../views/SignUp/SignOne.vue')
    },
    {
        path: '/signtwo',
        name: '/Signtwo',
        component: () =>
            import ('../views/SignUp/SignTwo.vue')
    },
    //忘记密码
    {
        path: '/forget',
        name: '/Forget',
        component: () =>
            import ('../views/Forget/forget.vue')
    },
    {
        path: '/resetpwd',
        name: '/Resetpwd',
        component: () =>
            import ('../views/Forget/resetpwd.vue')
    },
    //终端用户tab
    {
        path: '/main',
        name: 'main',
        component: () =>
            import ('../views/index.vue'),
        redirect: '/main/sitedetail',
        children: [{
            path: '/main/sitedetail',
            component: () =>
                import ('../views/SiteDetail.vue')
        }, {
            path: '/main/inverter',
            component: Inverter
        }, {
            path: '/main/alarm',
            component: Alarm
        }, {
            path: '/main/user',
            component: () =>
                import ('../views/userAccount.vue')
        }]
    },
    //添加电站
    {
        path: '/addsite',
        name: '/AddSite',
        component: () =>
            import ('../views/AddSite.vue')
    },
    //电站详情图表
    {
        path: '/sitechart',
        name: 'sitechart',
        component: () =>
            import ('../views/SiteChartIndex.vue'),
        redirect: '/sitechart/sitedetailchart',
        children: [{
                path: '/sitechart/sitedetailchart',
                component: () =>
                    import ('../views/SiteDetailchart.vue')
            },
            {
                path: '/sitechart/sitedetailEVchart',
                component: () =>
                    import ('../views/SiteDetailEVchart.vue')
            }
        ]
    },
    //电站下的逆变器列表
    {
        path: '/siteinvlist',
        name: '/Siteinvlist',
        component: () =>
            import ('../views/SiteInvList.vue')
    },
    //告警详情
    {
        path: '/alarmProposal',
        name: '/AlarmProposal',
        component: () =>
            import ('../views/AlarmProposal.vue')
    },
    {
        path: '/solar',
        name: '/Solar',
        component: () =>
            import ('../views/Solar.vue')
    },
    {
        path: '/battery',
        name: '/Battery',
        component: () =>
            import ('../views/Battery.vue')
    },
    {
        path: '/feedin',
        name: '/Feedin',
        component: () =>
            import ('../views/Feedin.vue')
    },
    {
        path: '/load',
        name: '/Load',
        component: () =>
            import ('../views/Load.vue')
    },
    //逆变器详情
    {
        path: '/inverterdetail',
        name: '/InverterDetail',
        component: () =>
            import ('../views/InverterDetail.vue')
    },
    //电池详情
    {
        path: '/batterydetail',
        name: '/BatteryDetail',
        component: () =>
            import ('../views/BatteryDetail.vue')
    },
    //Wifi Connection
    {
        path: '/wifi',
        name: '/wifi',
        component: () =>
            import ('../views/Wifi.vue')
    },
    {
        path: '/wificonn',
        name: '/wificonn',
        component: () =>
            import ('../views/WifiConn.vue')
    },
    //电价管理
    {
        path: '/electricity',
        name: '/Electricity',
        component: () =>
            import ('../views/Electricity.vue')
    },
    {
        path: '/operatfile',
        name: '/OperatFile',
        component: () =>
            import ('../views/OperatFile.vue')
    },
    //充电桩
    {
        path: '/chargerlist',
        name: '/chargerlist',
        component: () =>
            import ('../views/Charging/ChargerList.vue')
    },
    {
        path: '/chargerdetail',
        name: '/chargerdetail',
        component: () =>
            import ('../views/Charging/ChargerDetail.vue')
    },
    {
        path: '/chargerdetailchart',
        name: '/chargerdetailchart',
        component: () =>
            import ('../views/Charging/ChargerDetailchart.vue')
    },
    {
        path: '/chargersetting',
        name: '/chargersetting',
        component: () =>
            import ('../views/Charging/Settings.vue')
    },
    //本地登录
    {
        path: '/localin',
        name: 'localin',
        component: () =>
            import ('../views/Local/Login.vue'),
    },
    //本地设置tab
    {
        path: '/local',
        name: 'local',
        component: () =>
            import ('../views/Local/index.vue'),
        redirect: '/local/localflow',
        children: [{
            path: '/local/localflow',
            component: () =>
                import ('../views/Local/LocalFlow.vue')
        }, {
            path: '/local/alarm',
            component: () =>
                import ('../views/Local/Alarm.vue')
        }, {
            path: '/local/data',
            component: () =>
                import ('../views/Local/Data.vue')
        }]
    }
]

const router = new VueRouter({
    routes
})

export default router